<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html >
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'buy.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" type="text/css" href="res/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="res/css/bootstrap-responsive.min.css">
    <link rel="stylesheet" type="text/css" href="res/css/style.css">
    
    <script type="text/javascript" src="res/js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="res/js/bootstrap.min.js"></script>

  </head>
  
  <body>
    <input type="button" onclick="buy()" value="buy">
    <br>
    <span id="result"></span>
    
    
    <!-- Button to trigger modal -->
    <a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>
    <input type="button" onclick="openDialog()" value="openDialog">
     
    <!-- Modal -->
    <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog">
    	<div class="modal-header">
    		<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    		<h3 id="myModalLabel">订单商品明细</h3>
   		</div>
    	<div class="modal-body">
    		<p>One fine body…</p>
    	</div>
    	<div class="modal-footer">
		    <button class="btn" onclick="closeDialog()">Close</button>
		    <button class="btn btn-primary">Save changes</button>
   		</div>
    </div>
    
    
    <script type="text/javascript">
    
    
    function openDialog(){
    
    	$('#myModal').on('show', function(){
    		
    		var that = $(this);
    		alert("111");
    	
    	});
    
    	$('#myModal').modal({
    		remote : "http://localhost:8080/SilverBox/shop/toListShopVipLevel.htm",
    		show : true
    	});
    	
    }
    
    function closeDialog(){
    	$('#myModal').modal('hide');
    }
    
    function buy(){
    
    	var obj = {
			shopperId : 1, 
			customId : 1, 
			machineId : 1, 
			totalPrice : 180,
			itemBuyGoodsIds : [1,2,3],
			itemBuyTypes : ["默认","默认","默认"],
			itemBuyCounts : [3,3,3],
			itemBuyPrices : [30,60,90]
		};
    
    	var params = decodeURIComponent($.param(obj, true));
    
    	$.ajax({
			type: "post",
			data: params,
			url: "ajax/buyGoods.htm",
			beforeSend: function(XMLHttpRequest){
					
			},
			success: function(data, textStatus){
				$("#result").append(data);
			}
		});
    }
    
    </script>
  </body>
</html>
